package com.turing.usdtpay.mvp.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.turing.usdtpay.R;
import com.turing.usdtpay.base.BaseActivity;
import com.turing.usdtpay.mvp.fragment.OrderManagerFragment;
import com.turing.usdtpay.mvp.fragment.RobOrderFragment;
import com.turing.usdtpay.mvp.view.BaseTitleView;

/**
 * @作者：JAY
 * @创建时间：2019/10/15 11:50
 * @描述：
 **/
public class RodOrderActivity extends BaseActivity {

    private FrameLayout mFragment;
    private LinearLayout mRobLayount,mOrderLayout,mMoneyLayout,mAccountLayout;
    private BaseTitleView mTitle;
    private ProgressBar mProgress;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rob);
        initView();
        initTitle();
        initFragment();
    }

    private void initFragment() {
        setContainerId(R.id.base_fragment);
        addFragmentToStack(RobOrderFragment.newInstance(null));
    }

    private void initView() {
        mTitle = (BaseTitleView) findViewById(R.id.title);
        mRobLayount = (LinearLayout) findViewById(R.id.rob_layout);
        mOrderLayout = (LinearLayout) findViewById(R.id.order_layout);
        mMoneyLayout = (LinearLayout) findViewById(R.id.money_layout);
        mAccountLayout = (LinearLayout) findViewById(R.id.account_layout);
        mFragment = (FrameLayout) findViewById(R.id.base_fragment);
        mProgress = (ProgressBar) findViewById(R.id.progress);
        mRobLayount.setOnClickListener(this);
        mOrderLayout.setOnClickListener(this);
        mMoneyLayout.setOnClickListener(this);
        mAccountLayout.setOnClickListener(this);
    }

    private void initTitle() {
        mTitle.setLogoShow(false);
        mTitle.setLeftShow(false);
        mTitle.setTitle("抢单");
    }

    @Override
    protected void setTitle(String title) {
        mTitle.setTitle(title);
    }

    @Override
    protected void showBackBtn(boolean show) {
        mTitle.setLeftShow(show);
    }

    @Override
    protected void setBackListener(View.OnClickListener listener) {
        mTitle.setLeftButtonListener(listener);
    }


    @Override
    public void onClick(View v) {
        if (v.getId() == mRobLayount.getId()){
            popBack(1);
//            addFragmentToStack(RobOrderFragment.newInstance(null));
        }else if (v.getId() == mOrderLayout.getId()){
            startActivity(new Intent(RodOrderActivity.this,OrderManagerActivity.class));
            finish();
        }else if (v.getId() == mMoneyLayout.getId()){
            startActivity(new Intent(RodOrderActivity.this,MoneyActivity.class));
            finish();
        }else if (v.getId() == mAccountLayout.getId()){
            startActivity(new Intent(RodOrderActivity.this,AccountActivity.class));
            finish();
        }
    }



    @Override
    protected void showProgressBar(boolean show) {
        if (show){
            mProgress.setVisibility(View.VISIBLE);
        }else {
            mProgress.setVisibility(View.GONE);
        }
    }
}
